The Dreamweaver JavaScript API > Selection functions > dom.offsetsToNode() |
![]() ![]() ![]() |
Availability
Dreamweaver 3.0
Description
Gets the object in the DOM tree that completely contains the range of characters between the specified begin and end points. Valid for any document on a local drive.
Arguments
offsetBegin
, offsetEnd
The arguments are the begin and end points, respectively, of a range of characters, expressed as character offsets from the beginning of the document's HTML source code.
Returns
The tag, text, or comment object that completely contains the specified range of characters.
Enabler
None.
Example
The following code displays an alert if the selection is an image:
var offsets = dom.getSelection(); var theSelection = dreamweaver.offsetsToNode(offsets[0], ¬ offsets[1]); if (theSelection.nodeType == Node.ELEMENT_NODE && ¬ theSelection.tagName == 'IMG'){ alert('The current selection is an image.'); }
![]() ![]() ![]() |